#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"double_link.h"
#include"mystack.h"

#define NAMESIZE 32

typedef struct
{
	int id;
	char name[NAMESIZE];
	int math;
	int chinese;
}message_st;

static void print_st(const void *recod)
{
	const message_st *r = recod;
	printf("%d %s %d %d\n",r->id,r->name,r->math,r->chinese);
}

static int find(const void *record,const void *key)
{
	const message_st *dest = record;
	const int *src = key;
	return (*src - dest->id);
}


	int main()
{
	stack_head *stack = NULL;
	message_st temp;
	stack = stack_create(sizeof(message_st));
	
	for(int i = 0;i < 5;i++)
	{
		temp.id = i;
		snprintf(temp.name,NAMESIZE,"stu%d",i);
		temp.math = (rand() % 40)+60;
		temp.chinese = (rand() % 20)+60;
		stack_push(stack,&temp);
	}
	stack_display(stack,print_st);
	
	printf("\n");	
	stack_pop(stack,&temp);
	stack_display(stack,print_st);

	stack_destroy(stack);
	exit(0);
}
